package cn.ls.util;

import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNUpdateClient;

public class SvnUtil {

    /**
     * 根据svn帐号、密码、url，获取SvnRepository
     * @param url
     * @return
     */
    public static SVNRepository getSvnRepository(String url) throws SVNException {
        SVNClientManager manager;
        SVNUpdateClient updateClient;

        DefaultSVNOptions options = new DefaultSVNOptions();
        manager = SVNClientManager.newInstance(options, SvnConstants.SVN_USERNAME, SvnConstants.SVN_PASSWORD);
        updateClient = manager.getUpdateClient();
        updateClient.setIgnoreExternals(false);
        SVNRepository repository = manager.createRepository(SVNURL.parseURIEncoded(url), true);
        return repository;
    }
}
